package com.jesterplayer;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockListActivity;
import com.actionbarsherlock.view.MenuItem;

public class NowPlayingActivity extends SherlockListActivity implements OnItemClickListener {

	public static ArrayList<String> songsPlay = new ArrayList<String>();
	static ArrayAdapter<String> adapter;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_now_playing);
		
		adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, songsPlay);
		
		ActionBar bar = getSupportActionBar();
		bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
		
		setListAdapter(adapter);
		
		ListView view = getListView();
		view.setOnItemClickListener(this);
	}
	
	
	public static void addToList(String file) {
		songsPlay.add(file);
		//adapter.notifyDataSetChanged();
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            overridePendingTransition(R.animator.activity_pull_down, 
            		R.animator.activity_push_down);
            return true;
        }
        return super.onOptionsItemSelected(item);
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		
		overridePendingTransition(R.animator.activity_pull_down,
				R.animator.activity_push_down);
	}


	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		PlaybackController.playSong(arg2);
	}
	
}
